﻿using BomComparisonModule.Model;

namespace BomComparisonModule.Services
{
    public class BomComparisonCoordinator
    //public class BomComparisonCoordinator : IBomComparisonCoordinator
    {
        //private readonly IExcelReader _excelReader;
        //private readonly IBomComparisonService _compareByPartNumber;
        private readonly IEventAggregator _ea;

        // 通过构造函数注入依赖
        public BomComparisonCoordinator(
            //IExcelReader excelReader,
            //IBomComparisonService comparisonService,
            IEventAggregator ea)
        {
            //_excelReader = excelReader;
            //_compareByPartNumber = comparisonService;
            _ea = ea;
        }

        public void ExecuteComparison(BomComparisonRequest request)
        {
            // 参数校验移至此处
            if (string.IsNullOrEmpty(request.FilePath1) || string.IsNullOrEmpty(request.FilePath2))
            {
                //return new BomCompareResult { IsSuccess = false, ErrorMessage = "文件路径不能为空" };
            }

            try
            {
                //var bom1 = _excelReader.ReadData(request.FilePath1, request.Map1);
                //var bom2 = _excelReader.ReadData(request.FilePath2, request.Map2);

                // 对比逻辑实现...
                //_compareByPartNumber.CompareBoms(bom1, bom2);
            }
            catch (Exception ex)
            {
                //return new BomCompareResult { IsSuccess = false, ErrorMessage = ex.Message };
            }


            // // 参数校验
            // ValidateRequest(request);

            // // 读取数据
            // var source = _reader.ReadBomData(request.FilePath1, request.Map1);
            // var target = _reader.ReadBomData(request.FilePath2, request.Map2);

            // // 执行对比
            // var result = _service.CompareBoms(source, target);

            // // 发布事件
            // _ea.Publish(new BomComparedEvent(result));

            // return ToBomCompareResult(result);
        }


    }

}
